package nl.jjsoft.airlock.utils
{
	import com.adobe.utils.StringUtil;
	
	import flash.filesystem.File;
	
	import nl.jjsoft.airlock.AirLockConstants;
	
	import org.swizframework.storage.ISharedObjectBean;
	
	public class DbUtils
	{
		private static const LAST_SELECTED_DB:String = "myLastDB";
		
		[Inject]
		public var so:ISharedObjectBean;
		
		public function DbUtils()
		{
		}

		public function getLastSelectedDB():String {
			var db:String = so.getString(LAST_SELECTED_DB);
			if (!StringUtil.stringHasValue(db)){
				db =  getDefaultFileLocation();
			}
			return db;
		}
		
		public function getDefaultFileLocation():String {
			return File.documentsDirectory.resolvePath(AirLockConstants.DB_FILENAME).nativePath;
		}	
		
		public function setLastSelectedDB(db:String):void {
			so.setString(LAST_SELECTED_DB, db);
		}
	}
}